#include <iostream>
using namespace std;

const int N = 1e6 + 10;
int g[N];
int n, m;
int main(int argc, char const *argv[])
{
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> g[i];
    while (m--)
    {
        int x;
        cin >> x;
        int l = 0, r = n - 1;
        // 左端点
        while (l < r)
        {
            int mid = r + l >> 1;
            if (g[mid] >= x)
                r = mid;
            else
                l = mid + 1;
        }
        if (g[l] != x)
        {
            cout << "-1 -1" << endl;
            continue;
        }
        cout << l << " ";
        r = n - 1;
        while (l < r)
        {

            int mid = r + l + 1 >> 1;
            if (g[mid] <= x)
                l = mid;
            else
                r = mid - 1;
        }
        cout << l << endl;
    }

    return 0;
}
